Fix: scroll to bottom on thread load - #460
Conversation
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 55 minutes and 52 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdds a Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile SummaryThis PR adds a mount-time Confidence Score: 5/5Safe to merge — the change is a focused, well-guarded one-shot scroll on mount with no regressions to the existing pin-to-top or streaming flows. No P0 or P1 issues found. The ref gate, the isStreaming guard, and the rAF deferral are all consistent with the existing patterns in the file. The architectural assumption that unmounts on thread switch is clearly documented in comments and enforced by ChatProvider/ThreadBody. No files require special attention. Important Files Changed
Reviews (1): Last reviewed commit: "Scroll to bottom when thread loads so la..." | Re-trigger Greptile |
There was a problem hiding this comment.
2 issues found across 1 file
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/components/chat/Messages.tsx">
<violation number="1" location="src/components/chat/Messages.tsx:140">
P2: Custom agent: **Flag AI Slop and Fabricated Changes**
Behavior-changing thread-load scroll fix was added without regression test coverage for the new initial-scroll path.</violation>
<violation number="2" location="src/components/chat/Messages.tsx:146">
P2: This early return leaves the initial bottom-scroll effect armed during active turns, so it can fire right after streaming ends and cause an unexpected jump to bottom.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
…mount `<Messages>` already remounts on every thread load (ChatProvider clears messages, ThreadBody routes through the skeleton during hydration), so React's mount lifecycle is the natural one-shot signal. Drops the ref guard and the messages.length/isStreaming deps that were causing a post-turn scroll jolt in brand-new threads. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Today Messages naturally remounts on thread switch because ChatProvider.selectThread calls setMessages([]) and ThreadBody routes through the loading skeleton during hydration. With the planned ChatRuntimesProvider + BoundChatProvider rebind pattern, useChat will swap to a cached Chat instance that already holds messages — there's no length-zero gap, so React would reconcile in place and the mount-once scroll effect would stop firing per thread. Keying by threadId guarantees a fresh mount per thread regardless of how the runtime is wired upstream. Costs nothing today and resets all per-thread state (lastMeasuredUser, prevStatusRef, initialTurnPinnedRef, virtua cache) cleanly across switches. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Fixes thread loading dropping users at the top of history instead of the latest exchange.
<Messages>now callsscrollToIndex(lastIndex, { align: "end" })on mount when messages exist and we're not streaming, landing the user at the bottom of the thread (typically the most recent assistant response). The existing pin-to-top behavior for new turns remains unchanged.Summary by CodeRabbit